package com.example.myapplication.part11;

import android.os.Bundle;
import android.widget.ListView;
import androidx.appcompat.app.AppCompatActivity;

import com.example.myapplication.R;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);

        ListView listView = findViewById(R.id.listView);

        // 示例数据
        List<Item> items = new ArrayList<>();
        items.add(new Item("Item 1", "Subtitle 1", R.drawable.ic_default_icon));
        items.add(new Item("Item 2", "Subtitle 2", R.drawable.ic_default_icon));
        items.add(new Item("Item 3", "Subtitle 3", R.drawable.ic_default_icon));

        // 创建自定义适配器
        CustomAdapter adapter = new CustomAdapter(this, items);

        // 设置适配器
        listView.setAdapter(adapter);
    }
}
